/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package model.dao;

import java.util.List;
import model.pojo.Chitietdeal;
import model.util.HibernateUtil;
import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.Session;

/**
 *
 * @author CUCAINHO
 */
public class ChiTietDealDAO {
    
    
     public static Chitietdeal LayChiTietDeal(int maDeal) { 
            
    Chitietdeal chiTietDeal = null;
    
    Session session = HibernateUtil.getSessionFactory().openSession();
    try {
            String hql = "from Chitietdeal deal where deal.maDeal =:maDeal"; 
            Query query = session.createQuery(hql);
            query.setString("maDeal", Integer.toBinaryString(maDeal));
                       
            //Query query = session.createQuery(hql);             
            chiTietDeal = (Chitietdeal) query.list().get(0);  
        }catch (HibernateException ex) 
        { //Log the exception 
            System.err.println(ex); 
        } 
        finally {
            session.close(); 
        } 
    return chiTietDeal; 
    }
}
